<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <%@include file="/common/common.jspf" %>
    <%--下拉搜索框除了依赖下面两个以外还依赖了bootstrap的相关组件以及jquery.js，
jquery.js和lyGrid.js会有冲突，注意位置    jquery.js放在lyGrid.js上面--%>
    <link rel="stylesheet" href="${ctx}/js/date/bootstrap_select.min.css">
    <script src="${ctx}/js/date/bootstrap_select.min.js"></script>

    <script type="text/javascript" src="${ctx}/js/device/managemt/managemt_edit.js">
    </script>
    <style type="text/css">
        .col-sm-3 {
            width: 15%;
            float: left;
        }

        .col-sm-9 {
            width: 35%;
            float: left;
        }
        label[class^="btn btn-default"]{
            margin-top: -4px;
        }
    </style>
</head>
<body>
<div class="l_err" style="width: 100%; margin-top: 2px;"></div>
<form id="form" name="form" class="form-horizontal" method="post"
      action="${ctx}/devicemanagemt/devicetype_editEntity.shtml">
    <section class="panel panel-default">
        <input type="hidden" class="form-control" value="${user.deviceId}"
               name="DeviceFormMap.deviceId" id="deviceId">
        <div class="panel-body">

            <div class="form-group">
                <label class="col-sm-3 control-label">设备编码</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control checkName"
                           name="DeviceFormMap.deviceCode" id="deviceCode"  value="${user.deviceCode}" readonly>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label">设备名称</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control checkName"
                               name="DeviceFormMap.deviceName" id="deviceName" value="${user.deviceName}" readonly>
                    </div>
                </div>

            </div>

            <div class="line line-dashed line-lg pull-in"></div>

            <div class="form-group">
                <label class="col-sm-3 control-label">设备种类</label>
                <div class="col-sm-9">
                    <select class="form-control selectpicker show-tick" data-live-search="true" name="DeviceFormMap.deviceTypeId" id="deviceTypeId" >
                        <c:forEach items="${list}" var="li">
                            <c:choose>
                                <c:when test="${li.deviceTypeId == user.deviceTypeId}">
                                    <option value="${li.deviceTypeId}" selected = "selected">${li.deviceTypeName}</option>
                                </c:when>
                                <c:otherwise>
                                    <option value="${li.deviceTypeId}">${li.deviceTypeName}</option>
                                </c:otherwise>
                            </c:choose>
                        </c:forEach>
                    </select>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">设备状态</label>
                    <div class="col-sm-9">
                        <select class="form-control selectpicker show-tick" data-live-search="true" name="DeviceFormMap.deviceStatus" id="deviceStatus" >
                                <option value="1" <c:if test="${user.deviceStatus == 1}">selected</c:if>>可用</option>
                                <option value="2" <c:if test="${user.deviceStatus == 2}">selected  </c:if>>不可用</option>
                        </select>
                    </div>
                </div>

            </div>

            <div class="line line-dashed line-lg pull-in"></div>

            <div class="form-group">
                <label class="col-sm-3 control-label">购买价格</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control checkName"
                           name="DeviceFormMap.devicePurchasePrice" id="devicePurchasePrice" value="${user.devicePurchasePrice}">
                    </select>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label">购买日期</label>
                    <div class="col-sm-9">
                        <input type="date" class="form-control checkabh"
                              name="DeviceFormMap.devicePurchaseDate" id="devicePurchaseDate" value="${user.devicePurchaseDate}" readonly>
                    </div>
                </div>
            </div>
            <div class="line line-dashed line-lg pull-in"></div>

            <div class="form-group">
                <label class="col-sm-3 control-label">生产日期</label>
                <div class="col-sm-9">
                    <input type="date" class="form-control checkabh"
                            name="DeviceFormMap.deviceManufactureDate" id="deviceManufactureDate" value="${user.deviceManufactureDate}" readonly>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label">保修期</label>
                    <div class="col-sm-9">
                        <%--<input type="date" class="form-control checkabh" name="deviceFaultFormMap.deviceend" id="deviceend">--%>
                        <input type="date" class="form-control checkabh"
                               name="DeviceFormMap.deviceServiceLife" id="deviceServiceLife" value="${user.deviceServiceLife}" readonly>
                    </div>
                </div>
            </div>

            <div class="line line-dashed line-lg pull-in"></div>
            <div class="form-group">
                <label class="col-sm-3 control-label">使用人</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control checkName"
                           name="DeviceFormMap.deviceKeeper" id="deviceKeeper" value="${user.deviceKeeper}">
                </div>
            </div>

        </div>
        <footer class="panel-footer text-right bg-light lter">
            <button type="submit" class="btn btn-success btn-s-xs">提交</button>
        </footer>
    </section>
</form>
<script type="text/javascript">
    $(document).ready(function(){
        $('select').selectpicker();

        $("#deviceCode").blur(function(){
            // console.log($("#deviceCode").val())
            var code =  $("#deviceCode").val();
            $.ajax({
                url: rootPath + "/devicemanagemt/devicemanagemt_isExsit.shtml?deviceCode=" + code,
                type: "GET",
                dataType : "json",// 这里的dataType就是返回回来的数据格式了html,xml,json
                async : false,
                cache : false,
                success: function(data) {
                   if("success" == data){
                       layer.msg("此设备已存在,请勿重复添加");
                   }
                }
            });

        });

    });
</script>
</body>
</html>